#!/bin/bash
# 判断参数个数
case $# in
    0)
        echo "错误: 未提供参数"
        exit 1
        ;;
    # 单参数：进程信息
    1)
    	echo -e "\033[31m ------------------进程基本信息------------------- \033[0m "
        echo -e "\033[31m 进程名 \033[0m "
        adb shell cat /proc/$1/status | grep -i 'Name'
        echo -e "\033[31m 进程UID \033[0m "
        adb shell cat /proc/$1/status | grep 'Uid'
        echo -e "\033[31m 主线程PID \033[0m "
        adb shell cat /proc/$1/status | grep 'Tgid'
        echo -e "\033[31m 进程Gid \033[0m "
        adb shell cat /proc/$1/status | grep 'Gid'
        echo -e "\033[31m 进程PID \033[0m "
        adb shell cat /proc/$1/status | grep 'Pid'
        echo -e "\033[31m 父进程PID \033[0m "
        adb shell cat /proc/$1/status | grep -i 'PPid'
        echo -e "\033[31m 进程状态 \033[0m "
        adb shell cat /proc/$1/status | grep -i 'State'
        echo -e "\n\033[31m ------------------进程adj信息------------------- \033[0m "
        echo -e "\033[31m 进程oom_adj \033[0m " 
        adb shell cat /proc/$1/oom_adj
        echo -e "\033[31m 进程oom_score \033[0m " 
        adb shell cat /proc/$1/oom_score
        echo -e "\033[31m 进程oom_score_adj \033[0m " 
        adb shell cat /proc/$1/oom_score_adj
        echo -e "\n\033[31m ------------------进程调度策略配置------------------- \033[0m "
        echo -e "\033[31m 进程cgroup \033[0m " 
        adb shell cat /proc/$1/cgroup
        echo -e "\033[31m 进程cpuset \033[0m " 
        adb shell cat /proc/$1/cpuset
        echo -e "\033[31m 进程CPU最小利用率 \033[0m "
        adb shell cat /proc/$1/sched | grep 'effective uclamp.min'
        echo -e "\033[31m 进程CPU最大利用率 \033[0m "
        adb shell cat /proc/$1/sched | grep 'effective uclamp.max'
        echo -e "\033[31m 进程调度策略 \033[0m "
        adb shell cat /proc/$1/sched | grep 'policy'
        echo -e "\033[31m 进程优先级 \033[0m " 
        adb shell cat /proc/$1/sched | grep 'prio'
        echo -e "\033[31m 进程亲核性 \033[0m "
        adb shell cat /proc/$1/status | grep 'Cpus_allowed_list'
        ;;
    2)
    	echo -e "\033[31m ------------------线程基本信息------------------- \033[0m "
        echo -e "\033[31m 线程名 \033[0m "
        adb shell cat /proc/$1/task/$2/status | grep -i 'Name'
        echo -e "\033[31m 线程UID \033[0m "
        adb shell cat /proc/$1/task/$2/status | grep 'Uid'
        echo -e "\033[31m 主线程PID \033[0m "
        adb shell cat /proc/$1/task/$2/status | grep 'Tgid'
        echo -e "\033[31m 线程Gid \033[0m "
        adb shell cat /proc/$1/task/$2/status | grep 'Gid'
        echo -e "\033[31m 进程PID \033[0m "
        adb shell cat /proc/$1/task/$2/status | grep 'Pid'
        echo -e "\033[31m 父进程PID \033[0m "
        adb shell cat /proc/$1/task/$2/status | grep -i 'PPid'
        echo -e "\033[31m 线程状态 \033[0m "
        adb shell cat /proc/$1/task/$2/status | grep -i 'State'
        echo -e "\n\033[31m ------------------线程adj信息------------------- \033[0m "
        echo -e "\033[31m 线程oom_adj \033[0m "
        adb shell cat /proc/$1/task/$2/oom_adj
        echo -e "\033[31m 线程oom_score \033[0m "
        adb shell cat /proc/$1/task/$2/oom_score
        echo -e "\033[31m 线程oom_score_adj \033[0m "
        adb shell cat /proc/$1/task/$2/oom_score_adj
        echo -e "\n\033[31m ------------------线程调度策略配置------------------- \033[0m "
        echo -e "\033[31m 线程cgroup \033[0m " 
        adb shell cat /proc/$1/task/$2/cgroup
        echo -e "\033[31m 线程cpuset \033[0m " 
        adb shell cat /proc/$1/task/$2/cpuset
        echo -e "\033[31m 线程CPU最小利用率 \033[0m "
        adb shell cat /proc/$1/task/$2/sched | grep 'effective uclamp.min'
        echo -e "\033[31m 线程CPU最大利用率 \033[0m "
        adb shell cat /proc/$1/task/$2/sched | grep 'effective uclamp.max'
        echo -e "\033[31m 线程调度策略 \033[0m "
        adb shell cat /proc/$1/task/$2/sched | grep 'policy'
        echo -e "\033[31m 线程优先级 \033[0m "
        adb shell cat /proc/$1/task/$2/sched | grep 'prio'
        echo -e "\033[31m 线程亲核性 \033[0m "
        adb shell cat /proc/$1/task/$2/status | grep 'Cpus_allowed_list'
        ;;
    *)
        echo "错误: 传入参数过多"
        exit 1
        ;;
esac
